package com.controller.common;

import com.alibaba.fastjson.JSONObject;
import com.model.base.Result;

import com.common.utils.SystemInfoUtils;
import com.core.springSecurity.service.PermissionService;
import com.model.vo.sys.common.SystemInfosVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.UnknownHostException;

/**
 * @Author: zql
 * @Description:
 * @Data: 2021-07-14
 */
@Api(tags = {"服务监控"})
@Slf4j
@RestController
@RequestMapping("/v1")
public class MonitoringController {

    /**
     * @Author: zql
     * @Description:
     * @Date : 2021-07-23
     * @return : com.model.base.Result<com.model.vo.common.SystemInfosVO>
     */
    @ApiOperation(value = "获取系统监控信息")
    //@Log(title = "获取系统监控信息" ,businessType = BusinessType.OTHER,isSaveRequestData=true)
    @PostMapping("/getSystemInfos")
    @PreAuthorize("@ss.hasAnyPermi('" + PermissionService.SYSTEM_OPERATE + "')")
    public Result<SystemInfosVO> getSystemInfos() {
        JSONObject info = new JSONObject();
        try {
            info = SystemInfoUtils.getInfo();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return Result.suc(info.toJavaObject(SystemInfosVO.class));
    }
}
